<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改厂家信息档案')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css" />
    <link href="../static/css/bootstrap-select.min.css" th:href="@{/css/bootstrap-select.min.css}" rel="stylesheet"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-factory-edit" th:object="${zsyhPlatformFactory}">
            <input id="factoryProvinceName" name="factoryProvinceName" class="form-control" type="hidden">
            <input id="factoryCityName" name="factoryCityName"  class="form-control" type="hidden">
            <input id="factoryDistrictName" name="factoryDistrictName" class="form-control" type="hidden">
            <input id="factoryId" name="id" th:field="*{id}" type="hidden">
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">厂家名称：</label>
                        <div class="col-sm-8">
                            <input name="factoryName" autocomplete="off" th:field="*{factoryName}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">厂家登录密码：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input id="factoryPassword" name="factoryPassword" th:value="*{factoryPassword}" class="form-control" type="password" required>
                                <span class="input-group-addon" title="登录密码,鼠标按下显示密码"
                                      onmousedown="$('#factoryPassword').attr('type','text')"
                                      onmouseup="$('#factoryPassword').attr('type','password')"><i class="fa fa-key"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">厂家负责人：</label>
                        <div class="col-sm-8">
                            <input name="factoryPerson" autocomplete="off" th:field="*{factoryPerson}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">负责人手机号：</label>
                        <div class="col-sm-8">
                            <input name="factoryPhone" autocomplete="off" th:field="*{factoryPhone}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">所属区域：</label>
                        <div class="col-sm-8">
                            <select class="selectpicker form-control" id="factoryProvice" name="factoryProvice" >
                                <option value="" th:value="*{factoryProvice}" th:text="*{factoryProvinceName}">&#45;&#45;省份&#45;&#45;</option>
                            </select>
                            <select class="selectpicker form-control" id="factoryCity" name="factoryCity" >
                                <option value="" th:value="*{factoryCity}" th:text="*{factoryCityName}">&#45;&#45;城市&#45;&#45;</option>
                            </select>
                            <select class="selectpicker form-control" id="factoryDistrict" name="factoryDistrict" >
                                <option value="" th:value="*{factoryDistrict}" th:text="*{factoryDistrictName}">&#45;&#45;县区&#45;&#45;</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">厂家详细地址：</label>
                        <div class="col-sm-8">
                            <input name="factoryAddress" autocomplete="off" th:field="*{factoryAddress}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">厂家账户余额：</label>
                        <div class="col-sm-8">
                            <input name="factoryBalance" th:field="*{factoryBalance}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">厂家账户保证金：</label>
                        <div class="col-sm-8">
                            <input name="factoryMoney" autocomplete="off" th:field="*{factoryMoney}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">抽成比例：</label>
                        <div class="col-sm-8">
                            <input name="factoryProportion" autocomplete="off" th:field="*{factoryProportion}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">邮箱地址：</label>
                        <div class="col-sm-8">
                            <input name="factoryEmail" autocomplete="off" th:field="*{factoryEmail}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">厂家头像：</label>
                        <div class="col-sm-8">
                            <!--<img class="img-circle img-lg" th:src="${zsyhPlatformFactory.factoryImages}" >-->
                            <img class="img-circle img-lg" th:src="@{${zsyhPlatformFactory.factoryImages}}" >
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">厂家昵称：</label>
                        <div class="col-sm-8">
                            <input name="factoryNickname" th:field="*{factoryNickname}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">状态：</label>
                        <div class="col-sm-8">
                            <select name="factoryState" class="form-control m-b" th:with="type=${@dict.getType('zsyh_review')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{factoryState}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">驳回原因：</label>
                        <div class="col-sm-8">
                            <input name="rejectionReason" th:field="*{rejectionReason}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">厂家合作产品：</label>
                        <div class="col-sm-8">
                            <textarea name="factoryProducts" autocomplete="off" class="form-control">[[*{factoryProducts}]]</textarea>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">备注：</label>
                        <div class="col-sm-8">
                            <textarea name="factoryRemarks" autocomplete="off" class="form-control">[[*{factoryRemarks}]]</textarea>
                        </div>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4">其他信息</h4>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">厂家用户协议：</label>
                        <div class="col-sm-8">
                            <input type="hidden" class="form-control" th:field="*{factoryProtocol}">
                            <div class="summernote" id="factoryProtocol"></div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">营业执照：</label>
                        <div class="col-sm-8">
                            <img onclick="avatar()" class="img-rounded img-lg" th:src="@{${zsyhPlatformFactory.factoryLicence}}" >
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <th:block th:include="include :: summernote-js" />
    <script src="../static/js/bootstrap-select.min.js" th:src="@{/js/bootstrap-select.min.js}"></script>
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/factory";

        $(document).ready(function(){
            // 地区下拉框初始化
            $("#factoryProvice").selectpicker({width:130, liveSearch: false, liveSearchPlaceholder: "搜索" });
            $("#factoryCity").selectpicker({width:130, liveSearch: false, liveSearchPlaceholder: "搜索" });
            $("#factoryDistrict").selectpicker({width:130, liveSearch: false, liveSearchPlaceholder: "搜索" });
        });// onReady

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/uploadOSS',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            }).on("filebatchselected", function(event, files) {
                $(this).fileinput("upload");
            })
            $(this).fileinput('_initFileActions');
        });

        $(function() {
            $('.summernote').each(function(i) {
                $('#' + this.id).summernote({
                    lang: 'zh-CN',
                    callbacks: {
                        onChange: function(contents, $edittable) {
                            $("input[name='" + this.id + "']").val(contents);
                        },
                        onImageUpload: function(files) {
                            var obj = this;
                            var data = new FormData();
                            data.append("file", files[0]);
                            $.ajax({
                                type: "post",
                                url: ctx + "common/uploadOSS",
                                data: data,
                                cache: false,
                                contentType: false,
                                processData: false,
                                dataType: 'json',
                                success: function(result) {
                                    if (result.code == web_status.SUCCESS) {
                                        $('#' + obj.id).summernote('insertImage', result.url);
                                    } else {
                                        $.modal.alertError(result.msg);
                                    }
                                },
                                error: function(error) {
                                    $.modal.alertWarning("图片上传失败。");
                                }
                            });
                        }
                    }
                });
                var content = $("input[name='" + this.id + "']").val();
                $('#' + this.id).summernote('code', content);
            })
        });

        function avatar() {
            var url = ctx + 'zsyh/factory/avatar/'+$("#factoryId").val();
            top.layer.open({
                type: 2,
                /*area: [$(window).width() + 'px', $(window).height() + 'px'],*/
                area: ['600px', '800px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0,
                title: "查看营业执照",
                content: url,
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

    </script>
</body>
</html>